USE FITHOU_FORUM
GO
SET dateformat dmy
go

IF(OBJECT_ID('sp_getDiembyID_Kyhoc','p') is not null)
BEGIN
	DROP PROC sp_getDiembyID_Kyhoc
END
GO
CREATE PROC sp_getDiembyID_Kyhoc(@PK_sNguoidungID1 varchar(20), @iKyhoc1 int)
AS
SELECT     tbl_Diem.PK_iDiemID, tbl_Diem.fDiemchuyencan, tbl_Diem.fDiemthi, tbl_Diem.fDiemdieukien, tbl_Diem.iLanthu, tbl_Diem.iKyhoc, tbl_Monhoc.sTenmonhoc
FROM         tbl_Diem INNER JOIN
                      tbl_Monhoc ON tbl_Diem.FK_iMonID = tbl_Monhoc.PK_iMonhocID INNER JOIN
                      tbl_Nguoidung ON tbl_Diem.FK_sSinhvienID = tbl_Nguoidung.PK_sNguoidungID
WHERE     (tbl_Nguoidung.PK_sNguoidungID = @PK_sNguoidungID1) AND (tbl_Diem.iKyhoc = @iKyhoc1)
GO
--exec sp_getDiembyID_Kyhoc 'SV08B602',7

IF(OBJECT_ID('sp_getLichhoc_Lop','p') is not null)
BEGIN
	DROP PROC sp_getLichhoc_Lop
	
END
GO
CREATE PROC sp_getLichhoc_Lop(@sTenLop1 nvarchar(30))
AS
SELECT  tbl_Lichhoc.sGiobatdau, tbl_Lichhoc.sGioketthuc, tbl_Phonghoc.sTenphong, tbl_Monhoc.sTenmonhoc, tbl_Nguoidung.sHoten, tbl_Lichhoc.iTrangthai,tbl_Lichhoc.dNgayhoc
FROM         tbl_Lichhoc INNER JOIN
                      tbl_Lophoc ON tbl_Lichhoc.FK_iLophocID = tbl_Lophoc.PK_iLophocID INNER JOIN
                      tbl_Phonghoc ON tbl_Lichhoc.FK_iPhonghocID = tbl_Phonghoc.PK_iPhonghocID INNER JOIN
                      tbl_Monhoc ON tbl_Lichhoc.FK_iMonhocID = tbl_Monhoc.PK_iMonhocID INNER JOIN
                      tbl_Nguoidung ON tbl_Lichhoc.FK_sGiangvienID = tbl_Nguoidung.PK_sNguoidungID
WHERE     (tbl_Lophoc.sTenlop = @sTenlop1)
